<?php
    $userId = isset($user["id"]) ? intval($user["id"]) : $_SESSION["userId"];
    $username = isset($user["username"]) ? trim($user["username"]) : $_SESSION["username"];
    $type_display = isset($_SESSION["type_display"]) ? intval($_SESSION["type_display"]):0;
    $icon_w = isset($layout["icon_w"]) && $layout["icon_w"] !="" ? $layout["icon_w"]: LoadConfig::$type_display[$type]["icon_w"];
    $icon_h = isset($layout["icon_h"]) && $layout["icon_h"] !="" ? $layout["icon_h"]: LoadConfig::$type_display[$type]["icon_h"];
    $bg_color = isset($layout["bg_color"]) && $layout["bg_color"] !="" ? "#".$layout["bg_color"]: LoadConfig::$type_display[$type]["bg_color"];
    $text_color = isset($layout["text_color"]) && $layout["text_color"] !="" ? "#".$layout["text_color"]: LoadConfig::$type_display[$type]["text_color"];
    $intro_text_color = isset($layout["intro_text_color"]) && $layout["intro_text_color"] !="" ? "#".$layout["intro_text_color"]: LoadConfig::$type_display[$type]["intro_text_color"];
    $link_color = isset($layout["link_color"]) && $layout["link_color"] !="" ? "#".$layout["link_color"]: LoadConfig::$type_display[$type]["link_color"];
    $border_type = isset($layout["border_type"]) && $layout["border_type"] !="" ? $layout["border_type"]: LoadConfig::$type_display[$type]["border_type"];
    $border_size = isset($layout["border_size"]) && $layout["border_size"] !="" ? $layout["border_size"]."px": LoadConfig::$type_display[$type]["border_size"];
    $border_color = isset($layout["border_color"]) && $layout["border_color"] !="" ? "#".$layout["border_color"]: LoadConfig::$type_display[$type]["border_color"];
    $padding_size = isset($layout["padding_size"]) && $layout["padding_size"] !="" ? $layout["padding_size"]."px": LoadConfig::$type_display[$type]["padding_size"];
    
     if($item["categoryId"] >0){
        
        switch($item["type"]){
            case 1: //game
                $forder = "game";
                $domain = 2;
                $link_download = Yii::app()->params["url_hayquadi"].Url::createUrl("/fileGame/download",array("alias"=>$item["alias"],"gameId"=>$item["id"],"userId"=>$userId));
                break;
            default :
                $forder = "game";
                $domain = 2;
                $link_download = Yii::app()->params["url_hayquadi"].Url::createUrl("/fileGame/download",array("alias"=>$item["alias"],"gameId"=>$item["id"],"userId"=>$userId));
                break;
        }
        
        $link_img=Common::getImageDomain($item['picture'],$forder,$item['create_date'],'',$domain);
    }else{
        $link_download = Yii::app()->params["url_hayquadi"].Url::createUrl("/fileApp/download", array("userId"=>$userId, "alias"=>$item["alias"], "appId"=>$item["id"]));
        $link_img = Common::getImageDomain($item["picture"], "app",$item['create_date'], "",3);
    }

?>

<?php 
    // view box by type
    switch($type){
        case 1:
?>
<div class="CKHT_td">
        <div style="background:<?php echo $bg_color;?>;padding:<?php echo $padding_size;?>;border:<?php echo $border_type;?> <?php echo $border_size;?> <?php echo $border_color;?>">
           
                 <a href="<?php echo $link_download;?>" style="font-size:14px;color:<?php echo $text_color;?>">
                    <strong><?php echo $item["title"]?> </strong></a>
        </div>
 </div>                                            
<?php
        break;   
        case 2:
?>
<div class="CKHT_td">
             <div style="background:<?php echo $bg_color;?>;padding:<?php echo $padding_size;?>;border:<?php echo $border_type;?> <?php echo $border_size;?> <?php echo $border_color;?>">  
                <a href="<?php echo $link_download;?>" style="float:left;margin-right:5px">
                    <img src="<?php echo $link_img;?>" alt="" width="30" height="27" style="border:none medium; display:block"/>
                </a>
                <a href="<?php echo $link_download;?>" style="font-size:14px;color:<?php echo $text_color;?>">
                    <strong><?php echo $item["title"]?> </strong></a><br />
               
            </div>
</div>  
      
<?php                                     
         break;
         case 3:
?>
      <div class="CKHT_td">
             <div style="background:<?php echo $bg_color;?>;padding:<?php echo $padding_size;?>;border:<?php echo $border_type;?> <?php echo $border_size;?> <?php echo $border_color;?>">  
                <a href="<?php echo $link_download;?>" style="float:left;margin-right:5px">
                    <img src="<?php echo $link_img;?>" alt="" width="45" height="42" style="border:none medium; display:block"/>
                </a>
                <a href="<?php echo $link_download;?>" style="font-size:14px;color:<?php echo $text_color;?>">
                    <strong><?php echo $item["title"]?> </strong></a><br />
                <span style="color:<?php echo $intro_text_color;?>; font-size:small;"><?php echo $item["introtext"]?></span><br />
                <a href="<?php echo $link_download;?>" style="color:<?php echo $link_color;?>;font-size:small">Tải miễn phí</a>
            </div>
     </div>
<?php         
        break;
        case 4:
            
?>
    <div class="CKHT_td">
      <div style="background:<?php echo $bg_color;?>;padding:<?php echo $padding_size;?>;border:<?php echo $border_type;?> <?php echo $border_size;?> <?php echo $border_color;?>">
                    <a href="<?php echo $link_download;?>" style="float:left;margin-right:5px">
                        <img src="<?php echo $link_img;?>" alt="" width="65" height="62" style="border:none medium; display:block"/>
                    </a>
                    <a href="<?php echo $link_download;?>" style="font-size:14px;color:<?php echo $text_color;?>">
                        <strong><?php echo $item["title"]?> </strong></a><br />
                    <span style="color:<?php echo $intro_text_color;?>; font-size:small;"><?php echo $item["introtext"]?></span><br />
                    <a href="<?php echo $link_download;?>" style="color:<?php echo $link_color;?>;font-size:small">Tải miễn phí</a>
            </div>
    </div>
          
<?php         
            break;      
            case 5:
            
            
?>
      <div class="CKHT_td">
        <div style="background:<?php echo $bg_color;?>;padding:<?php echo $padding_size;?>;border:<?php echo $border_type;?> <?php echo $border_size;?> <?php echo $border_color;?>">
                   <div style="display:inline-block;width:100%">  
                    <a href="<?php echo $link_download;?>" style="float:left;margin-right:5px">
                        <img src="<?php echo $link_img;?>" alt="" width="90" height="87" style="border:none medium; display:block"/>
                    </a>
                    <a href="<?php echo $link_download;?>" style="font-size:14px;color:<?php echo $text_color;?>">
                        <strong><?php echo $item["title"]?> </strong></a><br />
                    <span style="color:<?php echo $intro_text_color;?>; font-size:small;"><?php echo $item["introtext"]?></span><br />
                    <a href="<?php echo $link_download;?>" style="color:<?php echo $link_color;?>;font-size:small">Tải miễn phí</a>
                </div>
         </div>
    </div>
<?php      
            break;     
            default :
?>
        <div class="CKHT_td">
        Kiểu 5:
          <input name="type_display" type="radio" value="<?php echo $type;?>" />
        <div style="background:<?php echo $bg_color;?>;padding:<?php echo $padding_size;?>;border:<?php echo $border_type;?> <?php echo $border_size;?> <?php echo $border_color;?>">
                   <div style="display:inline-block;width:100%">  
                    <a href="<?php echo $link_download;?>" style="float:left;margin-right:5px">
                        <img src="<?php echo $link_img;?>" alt="" width="90" height="87" style="border:none medium; display:block"/>
                    </a>
                    <a href="<?php echo $link_download;?>" style="font-size:14px;color:<?php echo $text_color;?>">
                        <strong><?php echo $item["title"]?> </strong></a><br />
                    <span style="color:<?php echo $intro_text_color;?>; font-size:small;"><?php echo $item["introtext"]?></span><br />
                    <a href="<?php echo $link_download;?>" style="color:<?php echo $link_color;?>;font-size:small">Tải miễn phí</a>
                </div>
         </div>
    </div>
    
<?php            
            break;   
    }
    
?>
